.fail movem.l (a7)+,d0/d1/a0/a1/a5/a6 ; if Z flag, fail!
beq.b .fail2
exg a0,d0
bra.b .ok
.fail2 moveq.l #0,d0
.ok rts
Lib OpenLib
add.w #1,LIB_OPENCNT(a6)
bset #LIBB_DELEXP,LIB_FLAGS(a6) ; MODULES DEFAULT ARE WANTED TO FREE THEIR MEMORY WHEN CLOSED SO THE EXPUGNE FLAG IS SET ,USUALLY. CLEAR IT ONLY IF REALLY NEEDED.